<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"> 

<ui:composition template="/_template.xhtml">
	<ui:define name="corpo">

		<div id="conteudo">
			<h:form id="form">

				<h2>
					<h:outputText value="Solicitação de Cadastro" />
				</h2>
				
				<p:messages id="msg"/>

				<p:fieldset legend="Dados do Funcionario" toggleable="true"><br />
				
					<h:outputLink value="javascript:void(0)" onclick="dlgSetor.show();">
						<h:outputLabel value="Setor do Funcionário: " />
					</h:outputLink>
					<p:inputText id="setor" required="true" requiredMessage="Preencha o campo Setor"
						value="#{funcionarioBean.funcionario.setor.nome}"
						onclick="dlgSetor.show();" readonly="true" rendered="true" onchange="handler">
					</p:inputText>
					<br />

					

					<!--<h:outputLink value="javascript:void(0)"
						onclick="dlgPerfil.show();">
						<h:outputLabel value="Acesso ao Sistema: " />
					</h:outputLink>
					<p:inputText id="perfil"
						value="#{funcionarioBean.funcionario.perfil.nome}" required="true" requiredMessage="Preencha o campo Perfil"
						onclick="dlgPerfil.show();">
					</p:inputText><br />-->

					<h:outputLabel value="Nome: " for="nome" />
					<p:inputText id="nome" value="#{funcionarioBean.funcionario.nome}" required="true" requiredMessage="Preencha o Nome">
						<f:ajax event="change" />
					</p:inputText><br />
										
					<h:outputLabel value="Matricula: " for="matricula" />
					<p:inputText id="matricula" value="#{funcionarioBean.funcionario.matricula}" required="true" requiredMessage="Preencha a Matricula"> 
						<f:ajax event="change" />
					</p:inputText><br />
					
					<h:outputLabel value="Campo Secreto: " for="secret" />
					<p:password id="secret" value="#{funcionarioBean.funcionario.campo_secreto}" feedback="false"> 
						<f:ajax event="change" />
					</p:password><br />
					
					<br />
					<p:commandButton value="Enviar" action="#{funcionarioBean.grava}" ajax="false">
						<f:ajax execute="true" render="@form" />
					</p:commandButton> 
					
					<p:button id="cancela" type="reset" value="Limpar" />
					
					<p:commandButton value="Voltar" readonly="true" rendered="true" update="form" 
						action="javascript:void(0)" onclick="dglVolta.show();" onstart="true">
					</p:commandButton> 
					
					</p:fieldset>		
				
			</h:form>

			<p:dialog header="Setores" widgetVar="dlgSetor" modal="true"
				width="800" showEffect="explode" hideEffect="explode" resizable="false" >
				<h:form id="form1">

					<p:outputPanel id="setores">
						<p:dataTable value="#{setorBean.setores}" var="setor"
							paginator="true" rows="5" selectionMode="single">
							
							<!-- <p:ajax event="rowSelect" oncomplete="dlgSetor.show()" /> --> 

							<p:column filterBy="#{setor.nome}" filterMatchMode="contains"
								headerText="Setor" sortBy="#{setor.nome}">
								<h:commandLink value="#{setor.nome}" onclick="dlgSetor.hide()"
									id="setor">
									<f:setPropertyActionListener target="#{funcionarioBean.funcionario.setor}" value="#{setor}" />
								</h:commandLink>
							</p:column>	
								
							<p:column headerText="Orgão" sortBy="#{setor.orgao.nome}">
								<h:outputText value="#{setor.orgao.nome}" />	
							</p:column>

						</p:dataTable>
					</p:outputPanel>
				</h:form>
			</p:dialog>	
			
				<p:dialog header="Cancelar Solicitação?" modal="true" showEffect="pulsate" hideEffect="size" widgetVar="dlgVolta">
				<h:form>
				<h:panelGrid columns="2" id="display">
					<p:commandButton value="SIM" action="login.xhtml" />
					<p:commandButton value="NAO" action="CadSolicitacao.xhtml?faces-redirect=true" />	
				</h:panelGrid>
				</h:form>
				</p:dialog>		

		</div>

	</ui:define>
</ui:composition>

</html>
